package com.example.friend.controller.question;


import com.example.common.core.Controller.BaseController;
import com.example.common.core.domin.R;
import com.example.common.core.domin.TableDataInfo;
import com.example.friend.domain.question.dto.QuestionQueryDTO;
import com.example.friend.domain.question.vo.QuestionDetailVO;
import com.example.friend.service.question.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/question")
@Tag(name = "C端题目接口")
public class QuestionController extends BaseController {


    @Autowired
    private IQuestionService questionService;

    //获取题目列表
    //接口地址: /question/semiLogin/list
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO queryDTO) {
        return questionService.list(queryDTO);
    }

    //获取题目详情
    //接口地址: /question/detail
    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId) {
        return R.ok(questionService.detail(questionId));
    }

    //题目顺序列表(redis) + 当前题目id
    //上一题 -- 参数当前题目id
    //redis list 数据类型  key: q:l  value: questionId
    //题目顺序列表: 先查redis,redis没数据,从mysql中同步过去
    @GetMapping("/preQuestion")
    public R<String> preQuestion(Long questionId) {

        return R.ok(questionService.preQuestion(questionId));
    }

    //下一题 -- 参数当前题目id
    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long questionId) {
        return R.ok(questionService.nextQuestion(questionId));
    }

}
